home *** CD-ROM | disk | FTP | other *** search
/ Chip: Internet / Chip Internet.iso / viewer / emtex.ins / dvineclq / dviproc.zoo / pctex / dvialwls.ps < prev    next >
Text File  |  1987-09-18  |  9KB  |  293 lines

  1. % <BEEBE.TEX.DVI>DVIALW.PS.17, 18-Sep-87 17:48:04, Edit by BEEBE
  2. % Add test for note paper and if unknown, use letter paper instead.
  3. % Non-Apple PostScript implementations do not know about note paper
  4. % but its use on the Apple LaserWriter gains 92K of virtual memory
  5. % <BEEBE.TEX.DVI>DVIALW.PS.16, 18-Sep-87 15:50:52, Edit by BEEBE
  6. % Modify coordinate computations to remove round-off errors
  7. % in landscape mode, and correct landscape page origin
  8. % <BEEBE.TEX.DVI>DVIALW.PS.14, 22-Jun-87 09:55:05, Edit by BEEBE
  9. % Add missing "0 900 translate Mtrx currentmatrix pop" to /LEGAL
  10. % <BEEBE.TEX.DVI>DVIALW.PS.13,  7-Jan-87 17:38:51, Edit by BEEBE
  11. % Add translate command to BOP so that (0,0) really corresponds to
  12. % the top left physical page corner.  The standard LaTeX file 
  13. % TESTPAGE.TEX can be used for this calibration; it might be sensitive
  14. % to the particular printer used.    
  15. % <BEEBE.TEX.DVI.NEW>DVIALW.PS.12, 10-Dec-86 17:24:50, Edit by BEEBE
  16. % Fix off-by-one error in definition of /B; to draw a box N pixels
  17. % wide, microscopic examination of output shows that the box width
  18. % must be N-1, not N, pixels; the boundary counts in the filling.                
  19. % <BEEBE.TEX.DVI.NEW>DVIALW.PS.9, 28-Nov-86 19:00:52, Edit by BEEBE
  20. % Change definition of EOP to use #copies and showpage
  21. % instead of {copypage} repeat erasepage
  22. % <BEEBE.TEX.DVI.NEW>DVIALW.PS.7, 16-Oct-86 13:09:36, Edit by BEEBE
  23. % Following Macintosh LaserWriter md dictionary, change most
  24. % def's to bdf's (bind def); this is claimed to speed up
  25. % operator access
  26. % <BEEBE.TEX.DVI.NEW>DVIALW.PS.5, 16-Oct-86 12:01:12, Edit by BEEBE
  27. % Change CTL-L to caret-L in comment
  28. % <BEEBE.TEX.DVI.NEW>DVIALW.PS.3, 13-Jun-86 10:48:39, Edit by BEEBE
  29. % Fix definition of NOTE, make it default in BOJ macro to try to reduce
  30. % incidence of VM errors
  31. % ----------------------------------------------------------------------
  32. % DVIALW PostScript macro definitions (keep in alphabetical order).  For
  33. % readability, these  are  heavily  commented,  but  we  adhere  to  the
  34. % convention that  percent is  used  ONLY to  mark  the beginning  of  a
  35. % comment (NEVER  occurs  inside a  PostScript  string), and  lines  are
  36. % limited to 80 characters.  That way, DVIALW can read these definitions
  37. % from a  file and  discard  comments and  trailing white  space  before
  38. % transmission to  the  PostScript output  file.   In the  interests  of
  39. % compactness, macros which  receive any significant  degree of use  are
  40. % given single letter names -- PostScript is already much too verbose.
  41. %
  42. % Coordinates are assumed to  be in pixels  (Resolution per inch).   The
  43. % page origin follows the  PostScript convention of  being in the  lower
  44. % left corner, y positive upwards along  the longer side of the page,  x
  45. % positive  to  the  right.   Letter  and  legal  sizes  are   therefore
  46. % equivalent as far as PostScript is concerned, but y coordinates can be
  47. % bigger in legal size.  In landscape mode, the page is rotated to place
  48. % the origin in  the upper left  corner, x positive  downward along  the
  49. % longer side of  the page, y  positive to the  right.  That way,  pages
  50. % eject from  the printer  upright when  viewed from  the front  of  the
  51. % printer.
  52. %
  53. % Document format is something like this:
  54. %
  55. %    %!PS-Adobe-1.0
  56. %    %%Dimensions: 0 0 612 792
  57. %    %%Title: DVIALW  -o1 -s300 foo12
  58. %    %%CreationDate: Sat Mar  8 10:52:52 1986
  59. %    %%Creator: BEEBE and [TeX82 DVI Translator Version 2.03b...]
  60. %    %%Pages: (atend)
  61. %    %%BugHistory: Incorporates save/restore and font reloading...
  62. %    %%BugHistory: Incorporates Allan Hetzel's 31-Oct-85 DARPA...
  63. %    %%EndComments
  64. %    %%EndProlog
  65. %    %%Page: 0 1
  66. %    TeXdict begin
  67. %    BOJ
  68. %    BOP
  69. %    ...
  70. %     1 EOP
  71. %    ^LBOP
  72. %    ...
  73. %     1 EOP
  74. %    ^LBOP
  75. %    ...
  76. %     1 EOP
  77. %    ^LEOJ
  78. %    %%Trailer
  79. %    %%Pages: 7
  80. %    %%PageTable:  0 1 3434
  81. %    ^D
  82. %
  83. % One formfeed is output  for each printed page  copy, in order to  make
  84. % spooler page accounting simple.  The additional comments wrapping  the
  85. % BOJ ..  EOJ  sequence conform  to  Adobe PostScript  file  structuring
  86. % conventions, and the first line can be used by the spooler to identify
  87. % the file as containing PostScript.
  88. % ----------------------------------------------------------------------
  89.  
  90.  
  91. /TeXdict 200 dict def        % dictionary for these definitions
  92. TeXdict begin
  93.  
  94. % bdf -- bind def (for efficiency)
  95. % Usage -- just like def, but not on constant objects
  96. /bdf {bind def} def
  97.  
  98. % B -- draw bar (TeX rule) of size w by h at currentpoint
  99. % Usage -- w h B
  100. /B
  101. {
  102.   /h exch def
  103.   /w exch def
  104.   gsave
  105.   currentpoint
  106.   newpath
  107.     moveto
  108.     w 1 sub 0 rlineto
  109.     0 h 1 sub rlineto
  110.     w 1 sub neg 0 rlineto
  111.   closepath fill
  112.   grestore
  113. } bdf
  114.  
  115. % BOJ -- beginning of job (EOF ends it and closes TeXdict)
  116. % Usage -- BOJ
  117. /BOJ
  118. {
  119.   72 Resolution div 72 Resolution div scale
  120.   LANDSCAPE                % Output in Landscape format
  121. } bdf
  122.  
  123. % BOP -- beginning of page
  124. % Usage -- BOP
  125. /BOP
  126. {
  127.   clear
  128.   Mtrx setmatrix
  129.   25 0 translate % Physical page origin is at (-25,0) from the top left corner
  130. } bdf
  131.  
  132. % ch-fieldname -- extract field from ch-data array (order defined by positions
  133. % in first array argument to macro D)
  134. % Usage -- ch-fieldname
  135. /ch-image  {ch-data 0 get} bdf    % the bitmap hex string image
  136. /ch-xoff   {ch-data 1 get} bdf    % pixels from left edge of bitmap to char origin
  137. /ch-yoff   {ch-data 2 get} bdf    % pixels from top edge of bitmap to char origin
  138. /ch-width  {ch-data 3 get} bdf    % bitmap width in pixels
  139. /ch-height {ch-data 4 get} bdf  % bitmap height in pixels
  140. /ch-tfmw   {ch-data 5 get} bdf    % pixels to next character (precise flt value)
  141.  
  142. % CharBuilder -- image one character
  143. % Usage -- fontdict ch CharBuilder
  144. /CharBuilder
  145. {
  146.   /ch-code exch def        % save the char code
  147.   /font-dict exch def        % and the font dict.
  148.   /ch-data font-dict /BitMaps get
  149.     ch-code get def        % get the bitmap descriptor for char
  150.   ch-data null eq not        % show character if entry is not empty
  151.   {
  152.     ch-tfmw                0
  153.     ch-xoff neg            ch-yoff ch-height sub
  154.     ch-width ch-xoff sub    ch-yoff
  155.     setcachedevice
  156.     0 0 SNAP translate
  157.     ch-width ch-height true [ 1 0 0 -1 ch-xoff ch-yoff ]
  158.     {ch-image} imagemask
  159.   } if
  160. } bdf
  161.  
  162.  
  163. % D -- define new character in current font
  164. % Usage -- [<bitmap> xoff yoff pixwid pixht tfmpixwid] charnum D
  165. /D
  166. {
  167.   /ch-code exch def
  168.   /ch-data exch def
  169.   currentfont /BitMaps get ch-code ch-data put
  170.   currentfont /Encoding get ch-code dup 3 string cvs cvn put
  171. } bdf
  172.  
  173. % EOJ -- end of job
  174. % Usage -- EOJ
  175. /EOJ
  176. {
  177.   end                % matches begin issued before BOJ
  178. } bdf
  179.  
  180. % EOP -- end of page
  181. % Usage -- ncopies EOP
  182. /EOP
  183. {
  184. /#copies exch def
  185. showpage
  186. } bdf
  187.  
  188. % LANDSCAPE -- landscape format page (11inH x 8.5inV)
  189. % Usage -- LANDSCAPE
  190. /LANDSCAPE
  191. {
  192.   letter initmatrix
  193.   72 Resolution div dup scale
  194.   0 3300 translate
  195.   -90 rotate
  196.   0 -750 translate
  197.   Mtrx currentmatrix pop
  198. } bdf
  199.  
  200. % LEGAL -- legal format page (8.5inH x 13inV)
  201. % Usage -- LEGAL
  202. /LEGAL
  203. {
  204.   legal initmatrix
  205.   72 Resolution div dup scale
  206.   0 900 translate
  207.   Mtrx currentmatrix pop
  208. } bdf
  209.  
  210. % LETTER -- letter format page
  211. % Usage -- LETTER
  212. /LETTER
  213. {
  214.   letter initmatrix
  215.   72 Resolution div dup scale
  216.   Mtrx currentmatrix pop
  217. } bdf
  218.  
  219. % M -- moveto
  220. % Usage -- x y M
  221. /M
  222. {
  223.   moveto
  224. } bdf
  225.  
  226. % Mtrx -- permanent storage for page transformation matrix
  227. % Usage -- Mtrx
  228. /Mtrx 6 array def
  229.  
  230. % NF -- define new font
  231. % Usage -- /fontname NF
  232. /NF
  233. {
  234.   /newname exch def
  235.   newname 7 dict def
  236.   newname load
  237.   begin
  238.     /BitMaps 128 array def
  239.     /BuildChar { CharBuilder } def
  240.     /Encoding 128 array def
  241.     0 1 127 { Encoding exch /.notdef put } for
  242.     /FontBBox [ 0 0 1 1 ] def
  243.     /FontMatrix [ 1 0 0 1 0 0 ] def
  244.     /FontType 3 def
  245.   end
  246.   newname newname load definefont pop
  247. } bdf() pop
  248.  
  249. % NOTE -- note format page (increases available virtual memory from 240K
  250. %      to 340K on Apple LaserWriter)
  251. % Usage -- NOTE
  252. /NOTE
  253. {
  254.   note initmatrix
  255.   72 Resolution div dup scale           % set scaling to 1.
  256.   Mtrx currentmatrix pop
  257. } bdf
  258.  
  259. % P -- show string at current point, updating horizontal position to new endpt
  260. % Usage -- (string) P
  261. /P {show} bdf() pop
  262.  
  263. % Q -- draw bar of last size set by B command at specified point
  264. % Usage -- x y Q
  265. /Q {moveto w h B} bdf() pop
  266.  
  267. % R -- move relative right and show string, updating horizontal position to
  268. %      new endpoint
  269. % Usage -- (string) xxx R
  270. /R {0 rmoveto show} bdf() pop
  271.  
  272. % Resolution -- device resolution in dots/inch
  273. % Usage -- Resolution
  274. /Resolution 300 def
  275.  
  276. % S -- move absolute and show string, updating horizontal position to new endpt
  277. % Usage -- (string) xxx yyy S
  278. /S {moveto show} bdf() pop
  279.  
  280. % SF -- set new font at scale nnn (nnn = 1 normally; 2 gives double size chars)
  281. % Usage -- nnn /fontname SF
  282. /SF {findfont exch scalefont setfont} bdf() pop
  283.  
  284. % SNAP -- convert coordinates to integer device coordinates and back again
  285. % Usage -- xxx yyy SNAP (leave xxx' yyy' on stack)
  286. /SNAP {transform 2 {floor 0.5 add exch} repeat itransform} bdf
  287.  
  288. % T -- move absolute horizontally and show string, updating horizontal position
  289. % to new endpt
  290. % Usage -- (string) xxx T
  291. /T {currentpoint exch pop moveto show} bdf() pop
  292.  
  293. end                % TeXdict